# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=wcwidth
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
         "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=0.1.7
pkgrel=2
pkgdesc="Measures number of Terminal column cells of wide-character codes (mingw-w64)"
url="https://github.com/jquast/wcwidth"
arch=('any')
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
#checkdepends=(
#  "${MINGW_PACKAGE_PREFIX}-python3-tox"
#  "${MINGW_PACKAGE_PREFIX}-python2-tox"
#)
source=(${_realname}-${pkgver}.tar.gz::https://github.com/jquast/${_realname}/archive/${pkgver}.tar.gz)
sha256sums=('c0122eb9a4ef7ab6489d0ef7c72db4143387b9466e27385cd5201950f49583b3')

prepare() {
  cp -a ${_realname}-${pkgver}{,-py2}
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}
  python3 setup.py build

  cd ${srcdir}/${_realname}-${pkgver}-py2
  python2 setup.py build
}

#check() {
#    cd ${srcdir}/${_realname}-${pkgver}
#    tox

#    cd ${srcdir}/${_realname}-${pkgver}-py2
#    tox
#}

package_python3-wcwidth() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/${_realname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}

package_python2-wcwidth() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/${_realname}-${pkgver}-py2
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
  install -Dm644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}

package_mingw-w64-i686-python2-wcwidth() {
  package_python2-wcwidth
}

package_mingw-w64-i686-python3-wcwidth() {
  package_python3-wcwidth
}

package_mingw-w64-x86_64-python2-wcwidth() {
  package_python2-wcwidth
}

package_mingw-w64-x86_64-python3-wcwidth() {
  package_python3-wcwidth
}

# vim:set ts=2 sw=2 et:
